#pragma once

#include <crtdbg.h> // use for debug: _ASSERT
#include <exception>

#ifndef ASSERT
#   define ASSERT(expr) _ASSERT(expr)
#endif


// single pointer deleter
template <typename T>
void delete_ptr(T*& ptr)
{
    delete ptr;
    ptr = nullptr;
}


// array pointer deleter
template <typename T>
void delete_array(T*& ptr)
{
    delete [] ptr;
    ptr = nullptr;
}


// validate a pointer
template <typename T>
void check_ptr(T const * const ptr, char const * const log)
{
    if (nullptr == ptr)
    {
        throw std::exception(log);
    }
}
